home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / Make-dist < prev    next >
Text File  |  1994-05-18  |  7KB  |  214 lines

  1. # Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3.  
  4. # The GNU C Library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Library General Public License as
  6. # published by the Free Software Foundation; either version 2 of the
  7. # License, or (at your option) any later version.
  8.  
  9. # The GNU C Library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. # Library General Public License for more details.
  13.  
  14. # You should have received a copy of the GNU Library General Public
  15. # License along with the GNU C Library; see the file COPYING.LIB.  If
  16. # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. # Cambridge, MA 02139, USA.
  18.  
  19. dist:
  20.  
  21. ifdef subdir
  22. .. := ../
  23. else
  24. .. :=
  25. endif
  26.  
  27. include $(..)Makeconfig
  28.  
  29. foo:=$(shell echo 'distribute=$(distribute)'>&2)
  30. foo:=$(shell echo 'foobar=$(filter %.c %.S %.s %.h,$(distribute))'>&2)
  31.  
  32. ifndef sysdep_dirs
  33. # Find all sysdep directories.
  34. export sysdep_dirs := $(shell find $(..)sysdeps -type d -print)
  35. else
  36. # Defined by the parent.
  37. sysdep_dirs := $(addprefix $(..),$(sysdep_dirs))
  38. endif
  39.  
  40. # Makefiles can define `source_dirs' to list nonstandard directories
  41. # where source files might be found.
  42.  
  43. ifdef    subdir
  44. all-headers = $(headers)
  45. else
  46. +distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t no_ir=t \
  47.              echo-distinfo | grep -v '^make')
  48. all-headers := $(patsubst +header+%,%,$(filter +header+%,$(+distinfo)))
  49. # Filter out the generated rpc headers; they don't have top-level indirections.
  50. # It is not safe to use `$(wildcard $(all-headers))' to ignore headers
  51. # without top-level indirections because some of $(all-headers) might need
  52. # to be found in sysdeps/.
  53. all-headers := $(filter-out rpcsvc/%,$(all-headers))
  54. +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo)))
  55. +subdir-headers := $(filter-out $(headers),$(all-headers))
  56. endif
  57. foo:=$(shell echo 'IS THIS WORKING??? all-headers=$(all-headers)' >&2)
  58.  
  59. # Find all sysdep sources and headers.
  60. +maybe-sysdeps := $(sources) $(sources:.c=.s) $(sources:.c=.S) $(all-headers) \
  61.           $(filter %.c %.S %.s %.h %.sub,$(distribute))
  62. foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
  63. # Find all the files that have a stub or generic version.
  64. try-sysdeps := $(foreach dir,$(..)sysdeps/stub $(..)sysdeps/generic,\
  65.                  $(addprefix $(dir)/,$(+maybe-sysdeps)))
  66. foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
  67. +sysdeps := $(wildcard $(try-sysdeps))
  68. foo:=$(shell echo 'stub/generic +sysdeps=$(+sysdeps)'>&2)
  69. +sysdep-names := $(sort $(notdir $(+sysdeps)))
  70. foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
  71.  
  72. # Now find all the sysdep versions of those files.
  73. +sysdeps := $(wildcard $(foreach dir,$(sysdep_dirs) $(source_dirs),\
  74.                  $(addprefix $(dir)/, \
  75.                          $(+sysdep-names) \
  76.                          $(+sysdep-names:.c=.s) \
  77.                          $(+sysdep-names:.c=.S) \
  78.                   )))
  79.  
  80.  
  81. # Source and header files to go in the distribution tar file.
  82.  
  83. .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
  84. sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
  85.  
  86. +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
  87.     $(addsuffix .c,$(sysdep_routines)) \
  88.     $(+subdir-nodist)
  89. #foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
  90. +tsrcs    := $(filter-out $(+out) $(addprefix %/,$(+out)), \
  91.             $(sources) $(all-headers) $(distribute)) \
  92.        $(+sysdeps)
  93. foo:=$(shell echo made +tsrcs >&2)
  94. foo:=$(shell echo generated='$(generated)' >&2)
  95. +tsrcs := $(sort $(filter-out $(generated),$(+tsrcs)))
  96. foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
  97. foo:=$(shell echo foobie, dammit! >&2)
  98.  
  99. ifndef tardir
  100. rel+vers := $(shell sed -n -e 's/^.*libc_release.*\"\([^"]*\)";$$/\1/p' \
  101.                -e 's/^.*libc_version.*\"\([^"]*\)";$$/\1/p' \
  102.             < $(..)version.c)
  103. release := $(word 1,$(rel+vers))
  104. version := $(word 2,$(rel+vers))
  105. export tardir := glibc-$(version)
  106. endif
  107.  
  108. $(..)glibc-$(version):
  109.     ln -s . $@
  110.  
  111. +tsrcs := $(+tsrcs) \
  112.       TAGS
  113. .PHONY: TAGS
  114. TAGS: $(..)MakeTAGS
  115.     $(MAKE) -f $< $@ -o subdir_TAGS
  116.  
  117. ifdef       subdir
  118.  
  119. foo:=$(shell echo subdir foo >&2)
  120.  
  121. +tsrcs := Makefile $(+tsrcs)                \
  122.       $(addsuffix .c,$(others) $(tests))        \
  123.       $(wildcard $(addsuffix .input,$(tests))    \
  124.       $(addsuffix .args,$(tests)))
  125. +tardeps := $(strip $(+tsrcs))
  126. +tsrcs := $(addprefix $(tardir)/$(subdir)/,$(+tardeps))
  127.  
  128. verbose = v
  129.  
  130. .PHONY: dist
  131. dist: $(..)$(tardir) $(+tardeps)
  132.     @cd ..; if test -f dist.tar; then c=u; else c=c; fi;    \
  133.     $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ...";    \
  134.     tar $${c}h$(verbose)f dist.tar $(+tsrcs)
  135.  
  136. else    # Parent makefile.
  137.  
  138. # Find what other things sysdep directories want to distribute.
  139.  
  140. foo:=$(shell echo parent foobie>&2)
  141. +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
  142. foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
  143. sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs)))
  144. ifdef sysdep-Subdir-files
  145. subdirs := $(sort $(subdirs) $(shell cat $(sysdep-Subdir-files)))
  146. endif
  147. +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
  148.               $(addprefix $(dir $(file)),$(shell cat $(file)))) \
  149.         $(+sysdep-distfiles) \
  150.         $(sysdep-Subdir-files)
  151. foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
  152.  
  153. subdirs := $(filter-out crypt,$(subdirs))
  154.  
  155. +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies \
  156.                            configure configure.in,\
  157.                       $(addsuffix /$(file),$(sysdep_dirs)))) \
  158.          $(+sysdep-dist)
  159.  
  160. +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
  161.  
  162. %/configure: %/configure.in
  163.     autoconf $(ACFLAGS) $< > $@.new
  164.     mv $@.new $@
  165.  
  166. .PHONY: dist
  167. dist: $(tardir).tar.gz $(tardir)-crypt.tar.gz
  168.  
  169. $(tardir)-crypt.tar.gz: crypt/crypt.tar.gz
  170.     ln $< $@
  171. crypt/%: FORCE
  172.     $(MAKE) -C $(@D) $(@F)
  173. FORCE:
  174.  
  175. subdir_dist: dist.tar
  176. dist.tar: $(tardir) $(+tsrcs)
  177.     tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
  178.  
  179. $(tardir).tar: dist.tar subdir_dist
  180.     tar xfv $< -C /tmp | doschk
  181.     tar covf $@ -C /tmp $(tardir)
  182.     -rm -fr /tmp/$(tardir) &
  183.  
  184. %.Z: %
  185.     compress -c $< > $@
  186.  
  187. %.gz: %
  188.     gzip -9 -v -c $< > $@
  189.  
  190. foo:=$(shell echo 'subdirs=$(subdirs)' >&2)
  191. dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
  192. .PHONY: subdir_dist $(dist-subdirs)
  193. subdir_dist: $(dist-subdirs)
  194. $(dist-subdirs):
  195.     $(MAKE) -C $(patsubst dist-%,%,$@) dist
  196.  
  197. # This is here instead of in Makefile so it can use $(release) and $(version).
  198. README: README.template version.c
  199.     -rm -f $@
  200.     sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
  201. # Make it unwritable so I won't change it by mistake.
  202.     chmod 444 $@
  203.  
  204.  
  205. endif    # Subdirectory vs. parent makefile
  206.  
  207. # Get these things out of the environment because they take up lots of space.
  208. unexport distribute generated
  209.  
  210. # Fnord.
  211. export inhibit_mach_syscalls=t
  212. export no_deps=t
  213. export inhibit_interface_rules=t
  214.